#include <Actor.h>
#include <ActorComponent.h>

Actor::Actor(ActorId id)
{
	m_id = id;
	m_type = "Unknown";
}

Actor::~Actor()
{

}

bool Actor::Init(tinyxml2::XMLElement* pData)
{
	m_type = pData->Attribute("type");
	return true;
}

void Actor::PostInit()
{
	for (ActorComponents::iterator it = m_components.begin(); it != m_components.end(); ++it)
	{
		it->second->VPostInit();
	}
}

void Actor::Destroy()
{
	m_components.clear();
}

void Actor::Update(double deltaSecs)
{
	for (ActorComponents::iterator it = m_components.begin(); it != m_components.end(); ++it)
	{
		it->second->VUpdate(deltaSecs);
	}
}

void Actor::AddComponent(StrongActorComponentPtr pComponent)
{
	std::pair<ActorComponents::iterator, bool> success = m_components.insert(
		std::make_pair(pComponent->VGetId(), pComponent));
}